package cn.kooki.app.duobao.util.manager;

import android.os.CountDownTimer;

/**
 * Created by xiong on 2015/12/14.
 */
public class ResultCounTDownTimer extends CountDownTimer {

    public interface TimerCallback{
        void notice(long millisUntilFinished);
        void finish();
    }

    private TimerCallback callback;

    public void setCallback(TimerCallback callback) {
        this.callback = callback;
    }

    /**
     * @param millisInFuture    The number of millis in the future from the call
     *                          to {@link #start()} until the countdown is done and {@link #onFinish()}
     *                          is called.
     * @param countDownInterval The interval along the way to receive
     *                          {@link #onTick(long)} callbacks.
     */
    public ResultCounTDownTimer(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onTick(long millisUntilFinished) {
        if (callback!=null){
            callback.notice(millisUntilFinished);
        }
    }

    @Override
    public void onFinish() {
        if (callback!=null){
            callback.finish();
        }
    }
}
